package main

import (
	"context"
	"git.900sui.cn/kc/base/utils"
	"git.900sui.cn/kc/kcgin"
	"git.900sui.cn/kc/kcgin/logs"
	"git.900sui.cn/kc/rabbitmq"
	"git.900sui.cn/kc/rpcinterface/client/order"
	"github.com/streadway/amqp"
)

/**
 * 支付成功，执行ping++账户充值
 */
func main() {
	mOrder := new(order.Pingpp).Init()   
	defer mOrder.Close()
	logs.Info("Environment Variable:MSF_ENV:", kcgin.KcConfig.RunMode)
	new(utils.KcLog).GetInstance(kcgin.AppConfig.String("order.log.pingppPaySucTask"))
	err := rabbitmq.Rabbitmq.Consume(kcgin.AppConfig.String("order.queue.pingppPaySucTask"), func(msg amqp.Delivery) {
		orderSn := string(msg.Body)
		var reply bool
		err := mOrder.PaySuc(context.Background(), &orderSn, &reply)
		if err != nil {
			utils.Logerr.Printf("ping++执行充值失败,orderSn:%s, err:%s", orderSn, err)
		}
	})
	if err != nil {
		utils.Logerr.Printf("ping++执行充值失败，err: %s", err.Error())
	}
}
